package com.cskaoyan.gateway.controller.user;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.user.annotation.Anoymous;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author TL
 * @created Date:2020/12/19 Time:16:58
 **/

@RestController
@RequestMapping("user")
@Anoymous
public class LogoutController {

    @GetMapping("loginOut")
    public ResponseData logoutUser(HttpServletRequest request, HttpServletResponse response){
        Cookie cookie = new Cookie("access_token","");
        cookie.setMaxAge(0);
        cookie.setPath("/");
        response.addCookie(cookie);
        return new ResponseUtil().setData(null);

    }
}
